//
//  STComposeButton.m
//  OCVVeibo
//
//  Created by leergou on 16/10/5.
//  Copyright © 2016年 WhiteHouse. All rights reserved.
//

#import "STComposeButton.h"
#import "STComposeButtonModel.h"

@implementation STComposeButton


// 重写 init方法
- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        [self setupUI];
    }
    return self;
}

#pragma mark - 重写模型set 方法，分发数组 - 
- (void)setButtonModel:(STComposeButtonModel *)buttonModel{
    _buttonModel = buttonModel;
    
    [self setTitle:buttonModel.title forState:UIControlStateNormal];
    [self setImage:[UIImage imageNamed:buttonModel.icon] forState:UIControlStateNormal];
}


#pragma mark - layoutSubviews -
- (void)layoutSubviews{
    [super layoutSubviews];
    
    // 设置imageView
    self.imageView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.width);
    
    // 设置title
    self.titleLabel.frame = CGRectMake(0, CGRectGetMaxY(self.imageView.frame), self.frame.size.width, self.frame.size.height - self.frame.size.width);
}

#pragma mark - setupUI -
- (void)setupUI{
    // 设置 imageView
    self.imageView.contentMode = UIViewContentModeCenter;
    // 设置 title
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    [self setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
}

#pragma mark - 干掉高亮效果 -
-(void)setHighlighted:(BOOL)highlighted{
    
}



@end
